<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\PayTypeSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Pay Types');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="pay-type-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a(Yii::t('app', '添加充值类型'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'sort',
            'tag',
            'payname',
            [
                'attribute'=>'icon',
                'format'=>'raw',
                'value'=>function($data){
                    return Html::img(Yii::getAlias('@bar').DIRECTORY_SEPARATOR.$data->pic,['width'=>'100']);
                }
            ],

             'fee',
             'rebate',
             'content:ntext',
             'addtime:date',
             [
                 'attribute'=>'isdisplay',
                 'value'=>function($data){
                    return $data->isdisplay==1?'显示':'不显示';
                 }
             ],
             [
                 'attribute'=>'status',
                 'value'=>function($data){
                    return $data->status==1?'启用':'不启用';
                 }
             ],

            [
                'class' => 'yii\grid\ActionColumn',
                'header'=>'操作',
                'template'=>'{update}{delete}',
                'buttons'=>[
                    'delete'=>function($url,$model){
                        if($model->id==1){
                            return '删除';
                        }else{
                            return Html::a("删除", ['paytype/delete','id'=>$model->id]);
                        }
                    },
                    'update'=>function($url,$model){
                        return Html::a("修改",['paytype/update','id'=>$model->id])."|";
                    }
                ],
            ],
        ],
    ]); ?>

</div>
